from flask_script import Manager,Shell
from app import db,app
from app.models import *
from flask_migrate import Migrate,MigrateCommand
migrate = Migrate()

migrate.init_app(app,db)
manager = Manager(app)
manager.add_command('db',MigrateCommand)

"""
数据库迁移命令
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
"""

@manager.command
def init_db():
    with app.app_context():
        db.create_all()

if __name__ == '__main__':
    # app.run()
    manager.run()